unit uPrintBarBill;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Oracle, uutils, gnugettext, umainutils;

type
  TFrmPrintBarBill = class(TForm)
    lbl_Player: TLabel;
    img_Logo: TImage;
    Label1: TLabel;
    lbl_TournamentName: TLabel;
    Label3: TLabel;
    lbl_PlayerName: TLabel;
    lbl_Value: TLabel;
    lbl_TotalValue: TLabel;
    lbl_DateTime: TLabel;
    lbl_DateTimeValue: TLabel;
    Label4: TLabel;
    lbl_Table: TLabel;
    OracleQuery1: TOracleQuery;
    tmr_CloseForm: TTimer;
    Label5: TLabel;
    lbl_Seat: TLabel;
    lbl_DrinkName: TLabel;
    procedure tmr_CloseFormTimer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure SetData(drink_order_id: string; OraSession: TOracleSession);
    procedure PrintBarBill();
  end;

var
  FrmPrintBarBill: TFrmPrintBarBill;

implementation

uses uFrmMain;
{$R *.dfm}
{ TFrmTicket }

procedure TFrmPrintBarBill.FormCreate(Sender: TObject);
begin
  gnugettext.TranslateComponent(self);
end;

procedure TFrmPrintBarBill.PrintBarBill;
begin
  print();
end;

procedure TFrmPrintBarBill.SetData(drink_order_id: string; OraSession: TOracleSession);
begin
  OracleQuery1.Session := OraSession;
  // img_Logo.Picture := uutils.GetImage('select IMAGE, IMAGE_TYPE from SETTINGS where id=1', OraSession);
  img_Logo.Picture := FrmMain.img_LogoSettings.Picture;
  OracleQuery1.Close;
  OracleQuery1.SQL.Text :=
    'SELECT DOR.ID, SEAT_NUM, PL.NAME||'' ''||PL.SURNAME AS PLAYER_NAME, (SELECT SYSDATE FROM DUAL) AS NOW,TA.NAME AS TABLE_NAME, DR.NAME AS DRINK_NAME, PRICE  FROM DRINK_ORDERS DOR' +
    ' LEFT JOIN PLAYERS PL ON DOR.PLAYER_ID=PL.ID LEFT JOIN TABLES TA ON TA.ID=DOR.TABLE_ID JOIN DRINKS DR ON DOR.DRINK_ID=DR.ID WHERE DOR.ID=' + drink_order_id;
  OracleQuery1.Execute;
  lbl_TotalValue.Caption := VarToStr(OracleQuery1.Field('price')) + ' ' + umainutils.Currency_Symbol;
  lbl_PlayerName.Caption := OracleQuery1.Field('PLAYER_NAME');
  lbl_DateTimeValue.Caption := OracleQuery1.Field('NOW');
  lbl_Table.Caption := OracleQuery1.Field('TABLE_NAME');
  lbl_Seat.Caption := OracleQuery1.Field('SEAT_NUM');
  lbl_DrinkName.Caption := OracleQuery1.Field('DRINK_NAME');
  show();
  self.Repaint;
  tmr_CloseForm.Enabled := true;
end;

procedure TFrmPrintBarBill.tmr_CloseFormTimer(Sender: TObject);
begin
  tmr_CloseForm.Enabled := false;
  Close();
end;

end.
